﻿namespace zijian666.Data;

/// <summary>
/// 命令拦截上下文
/// </summary>
public class DbExecuteNonQueryInterceptorContext : DbInterceptorContext
{
    public DbExecuteNonQueryInterceptorContext(IDbCommand command, long timestamp, int recordsAffected, CancellationToken cancellationToken)
        : base(command.Connection!, timestamp, cancellationToken)
    {
        Command = command;
        Batch = null;
        RecordsAffected = recordsAffected;
    }

    public DbExecuteNonQueryInterceptorContext(DbBatch batch, long timestamp, int recordsAffected, CancellationToken cancellationToken)
        : base(batch.Connection!, timestamp, cancellationToken)
    {
        Command = null;
        Batch = batch;
        RecordsAffected = recordsAffected;
    }

    public IDbCommand? Command { get; }
    public DbBatch? Batch { get; }

    public int RecordsAffected { get; }

}
